package com.verify.error;

import com.verify.util.R;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@RestControllerAdvice
public class PExceptionHandler {

    /**
     * 处理自定义异常
     */
    @ExceptionHandler({RuntimeException.class})
    public R handleRException(RuntimeException e, HttpServletRequest request, HttpServletResponse response) {
        return R.error(e.getMessage()).put("errorCause", e.getCause());
    }
}
